package com.yb.guigu.pick.web.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/6/1 10:55
 * FileName: DelayFilter
 * Description:
 */
public class DelayFilter implements Filter {

    private long time;

    public DelayFilter(long time){
        this.time=time;
    }

    public DelayFilter(){
        this.time=3000;
    }
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        chain.doFilter(request,response);
    }
}
